package com.liming.common.pojo.vo.product.web;

import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.liming.common.pojo.vo.product.BaseProductVO;
import com.liming.common.serializer.CentToYuanSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Arrays;
import java.util.List;

/**
 * @author liming
 * @date 2025/1/16
 */
@Data
@Schema(description = "商品VO")
@EqualsAndHashCode(callSuper = true)
public class ProductVO extends BaseProductVO {

    @Schema(description = "商品售价")
    @JsonSerialize(using = CentToYuanSerializer.class)
    private Integer price;

    @Schema(description = "商品原价）")
    @JsonSerialize(using = CentToYuanSerializer.class)
    private Integer originalPrice;

    @Schema(description = "商品参数信息")
    private String parameters;

    public List<String> getParameters() {
        if (ObjectUtil.isNull(parameters)) {
            return List.of();
        }
        return Arrays.asList(parameters.split(","));
    }
}
